home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 September & October / Amiga-CD 1997 #9-10.iso / aminet / gameboyemulator / vgb.c < prev    next >
C/C++ Source or Header  |  1995-10-29  |  2KB  |  89 lines

  1. /** VGB: portable GameBoy emulator ***************************/
  2. /**                                                         **/
  3. /**                           VGB.c                         **/
  4. /**                                                         **/
  5. /** This file contains generic main() procedure statrting   **/
  6. /** the emulation.                                          **/
  7. /**                                                         **/
  8. /** Copyright (C) Marat Fayzullin 1995                      **/
  9. /**     You are not allowed to distribute this software     **/
  10. /**     commercially. Please, notify me, if you make any    **/
  11. /**     changes to this file.                               **/
  12. /*************************************************************/
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <signal.h>
  19.  
  20. #include "GB.h"
  21. #include "Help.h"
  22.  
  23.  
  24. extern char *Title;
  25. //extern int   UseSHM;
  26. extern int   SaveCPU;
  27. extern word OldTrap;
  28. BOOL ScaleUp;
  29.  
  30. main(void)
  31. {
  32. LONG ArgPtrs[6]={0};
  33. struct RDArgs *Args;
  34. STRPTR filename_buf;
  35.  
  36.   TrapBadOps=1;LineDelay=0; 
  37.   VPeriod=10000;UPeriod=2;IntSync=1;
  38.   Verbose=5;
  39.  
  40.     if(Args = ReadArgs("Verbose/K/N,VP=VPeriod/K/N,UP=UPeriod/K/N,Trap/K,Help/S,DS=DoubleSize/S",ArgPtrs,NULL))
  41.     {
  42.         if(OPT_VERBOSE) Verbose = (int)(*OPT_VERBOSE);
  43.         if(OPT_VPER) VPeriod = (int)(*OPT_VPER);
  44.         if(OPT_UPER) UPeriod = (int)(*OPT_UPER);
  45.         if(OPT_TRAP) sscanf(OPT_TRAP,"%hx",&Trap);
  46.         if(OPT_HELP) {puts(HelpText); FreeArgs(Args); exit(0);}
  47.         ScaleUp = (OPT_SCALEUP);
  48.         FreeArgs(Args);
  49.         if((filename_buf = ReqFile()) == NULL) exit(0);
  50.  
  51.         if(!InitMachine()) return(1);
  52.         OldTrap=Trap;
  53.         StartGB(filename_buf);
  54.         TrashGB();
  55.         TrashMachine();
  56.  
  57.         FreeVec(filename_buf);
  58.         return(0);
  59.     }
  60. }
  61.  
  62. STRPTR ReqFile(void)
  63. {
  64. struct FileRequester *AslReq;
  65. STRPTR file=NULL;
  66. WORD namelen;
  67.  
  68.     if(AslReq = (struct FileRequester*)AllocAslRequestTags(ASL_FileRequest,
  69.             ASLFR_TitleText,"Select a cartridge!",
  70.             ASLFR_PositiveText,"Play!",
  71.             ASLFR_NegativeText,"Suxx!",
  72.             ASLFR_RejectIcons,TRUE,
  73.             TAG_END))
  74.     {
  75.         if(AslRequest(AslReq,NULL))
  76.         {
  77.             namelen = strlen(AslReq->fr_File) + strlen(AslReq->fr_Drawer) + 2;
  78.             if(file = AllocVec(namelen,MEMF_ANY | MEMF_CLEAR))
  79.             {
  80.                 strcpy(file,AslReq->fr_Drawer);
  81.                 AddPart(file,AslReq->fr_File,namelen);
  82.                 printf("Looking for file: '%s'\n",file);
  83.             }
  84.         }
  85.         FreeAslRequest((APTR)AslReq);
  86.     }
  87.     return file;
  88. }
  89.